<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<!--面板-->
<canvas id="canvas" style="background-color: #000000;">您当前的版本不支持，请升级版本！</canvas>
<script type="text/javascript">

    //拿到画板
    var canvas = document.getElementById('canvas');
    canvas.width = 1000;
    canvas.height = 700;

    //获取绘图上下文
    var context = canvas.getContext('2d');
    context.strokeStyle = 'red';
    context.lineWidth = 10;
    //设置填充的颜色
    context.fillStyle = 'blue';

    //绘制三角形
    context.beginPath();
    context.moveTo(100,100);
    context.lineTo(200,500);
    context.lineTo(300,400);
    context.lineTo(100,100);
    context.closePath();
    context.stroke();
    //填充
    context.fill();

    //绘制一个正方形
    context.beginPath();
    context.moveTo(300,300);
    context.lineTo(500,300);
    context.lineTo(500,500);
    context.lineTo(300,500);
    context.lineTo(300,300);
    context.closePath();
    context.stroke();
    //填充
    context.fill();

</script>
</body>
</html>